﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TestBat.IViewModels.Workspaces.Results;
using TestBat.IViewModels.Base;
using TestBat.IModels.Domain;
using System.Collections.ObjectModel;
using TestBat.ServiceLocator;
using Ninject.Core.Parameters;
using TestBat.IModels.Models;

namespace TestBat.ViewModels.Workspaces.Results
{
    public class ResultTestTaskListViewModel : ListViewModel<IResultTestTaskViewModel, ObservableCollection<IResultTestTaskViewModel>>, IResultTestTaskListViewModel
    {
        public ResultTestTaskListViewModel(ITest test, ITestTaskModel testTaskModel)
            : base(false)
        {
            this.test = test;
            this.testTaskModel = testTaskModel;
        }

        protected override ObservableCollection<IResultTestTaskViewModel> _RecreateItems()
        {
            ObservableCollection<IResultTestTaskViewModel> list = new ObservableCollection<IResultTestTaskViewModel>();

            foreach (var testTask in testTaskModel.Get(test))
            {
                IResultTestTaskViewModel testTaskViewModel = DefaultServiceLocator.Get<IResultTestTaskViewModel>(With.Parameters.ConstructorArgument("testTask", testTask));
                list.Add(testTaskViewModel);
            }

            return list;
        }

        private readonly ITest test;
        private readonly ITestTaskModel testTaskModel;
    }
}
